package com.xucranger.ojapi.controller;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.xucranger.ojapi.enity.DTO.StudentDTO;
import com.xucranger.ojapi.enity.DTO.StudentQueryDTO;
import com.xucranger.ojapi.enity.DTO.common.PageResultDTO;
import com.xucranger.ojapi.enity.DTO.common.ResponseDTO;
import com.xucranger.ojapi.enity.VO.StudentVO;
import com.xucranger.ojapi.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;


@RestController
@RequestMapping("/student")
public class StudentController {

    //分页查询
    @Autowired
    StudentService studentService;
    @PostMapping("/page/query")
    public ResponseDTO<PageResultDTO<StudentVO>> queryByPage(@RequestBody @Validated StudentQueryDTO queryDTO) {

        return studentService.queryByPage(queryDTO);
    }

    //注册
    @PostMapping("/register")
    public ResponseDTO<String> register(@RequestBody @Valid StudentDTO addDTO){
        return studentService.add(addDTO);
    }

    //更新
    @PostMapping("/update")
    public ResponseDTO<String> update(@RequestBody @Valid StudentDTO updateDTO){
        return studentService.update(updateDTO);
    }

    //根据id删除By王佳
    @GetMapping("/delete/{id}")
    public ResponseDTO<String> delete(String id){
        return studentService.delete(id);
    }

    //根据id列表删除
    @PostMapping("/deleteByIds")
    public ResponseDTO<String> deleteByids(@RequestBody String ids) {

        return studentService.deleteByIds(ids);
    }
}
